import pt.webdetails.cda.*

cda = new CdaQueryComponent()

//
// Execute CDA query
//

//setup inputs
cda.file = 'bi-developers/cda/cdafiles/sql-jndi.cda'
cda.inputs = [ dataAccessId:1 ]
               
//execute               
cda.execute()

//
// Process resultset
//

printStream.println "*** Resultset from CDA file ${cda.file} ***"
def res = cda.getResultSet()

rowCount = res.getRowCount()

printStream.println "row count: ${rowCount}"

for ( i in 1..rowCount ) {
  rowStr = ""
  res.next().each { col ->
    rowStr += "${col}\t"
  }
  printStream.println rowStr
}

//
//Create the report
//

reportAction = new SimpleReportingComponent()
reportAction.setQueryData(res)
reportAction.setOutputType("string")
reportAction.setReportDefinition(repo.get('incomestatement_external.prpt')
outStream << reportAction.outputStream //have to be able to detect here that we have not already written to the stream

// Alt:
// reportAction = actionFactory.get("ReportAction")  //you are actually getting back an action harness instance here, very handy
// if you want the actual IAction instance you can say reportAction.getBean() or something like that
// reportAction.setValues(...)
// reportAction.execute()
// someOutputValue = reportAction.getXXX()





























